package com.itheima.exception;

import com.itheima.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice//用来捕获controller层抛出的异常
//@ControllerAdvice
//@ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler//指定处理何种异常
    public Result doException(Exception exception){
        log.error("捕获异常{}",exception);
        return Result.error("出错了请联系管理员");
    }
}
